﻿using ReadAndWrite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Logging.LogCSV
{
    public class LoggingCSV : ILogService
    {
        public String NameApplication
        {
            get;
            private set;
        }

        public String PathApplication
        {
            get;
            private set;
        }

        public LoggingCSV(String nameApplication, String pathApplication)
        {
            NameApplication = nameApplication;
            PathApplication = pathApplication;
        }

        #region ILogService Membres

        public void WriteLog(Utils.LogTrace log)
        {
            String dateDay = DateTime.Now.ToShortDateString().Replace('/', '_');
            String path = PathApplication + @"\" + NameApplication + @"_" + dateDay + @".csv";

            ReadAndWriteCSV read = new ReadAndWriteCSV(path, ";");
            read.WriteCSV(new List<ISerializableCSV>() { log.CreateTrace() });
        }

        #endregion
    }
}
